package com.byxy.managerial.service.impl;


import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byxy.managerial.dao.UserDao;
import com.byxy.managerial.service.UserService;
import com.opensymphony.xwork2.ActionContext;

/**
 * 管理员service接口实现类
 * @author muxiangling
 *
 */
@Service
public class UserServiceImpl implements UserService {

	@Resource
	private UserDao userDao;

	@Override
	public boolean login(String username, String password) {
		if (userDao.getByName(username) == null) {
			return false;
		}
		if (userDao.getByName(username).getPassword().equals(password)) {
			// 登陆成功，将登录名存入session
			ActionContext.getContext().getSession().put("username", username);
			return true;
		}
		return false;
	}

	@Override
	public int countTotal() {
		return (int) userDao.countAll();
	}

}
